$OpenBSD: patch-src_openvpn_tun_c,v 1.14 2017/06/11 12:15:50 jca Exp $

- no need for link0 any more, we have separate tap interfaces

- fix bus error in write_tun_header() due to misaligned access
  https://github.com/OpenVPN/openvpn/commit/3e4e300d6c5ea9c320e62def79e5b70f8e255248

Index: src/openvpn/tun.c
--- src/openvpn/tun.c.orig
+++ src/openvpn/tun.c
@@ -1201,7 +1201,7 @@ do_ifconfig(struct tuntap *tt,
         if (tun)
         {
             argv_printf(&argv,
-                        "%s %s %s %s mtu %d netmask 255.255.255.255 up -link0",
+                        "%s %s %s %s mtu %d netmask 255.255.255.255 up",
                         IFCONFIG_PATH,
                         actual,
                         ifconfig_local,
@@ -1213,7 +1213,7 @@ do_ifconfig(struct tuntap *tt,
         {
             remote_end = create_arbitrary_remote( tt );
             argv_printf(&argv,
-                        "%s %s %s %s mtu %d netmask %s up -link0",
+                        "%s %s %s %s mtu %d netmask %s up",
                         IFCONFIG_PATH,
                         actual,
                         ifconfig_local,
@@ -1224,8 +1224,13 @@ do_ifconfig(struct tuntap *tt,
         }
         else
         {
+           /*
+            * OpenBSD has distinct tun and tap devices
+            * so we don't need the "link0" extra parameter to specify we want to do
+            * tunneling at the ethernet level
+            */
             argv_printf(&argv,
-                        "%s %s %s netmask %s mtu %d broadcast %s link0",
+                        "%s %s %s netmask %s mtu %d broadcast %s",
                         IFCONFIG_PATH,
                         actual,
                         ifconfig_local,
@@ -1654,11 +1659,11 @@ write_tun_header(struct tuntap *tt, uint8_t *buf, int 
     {
         u_int32_t type;
         struct iovec iv[2];
-        struct ip *iph;
+        struct openvpn_iphdr *iph;
 
-        iph = (struct ip *) buf;
+        iph = (struct openvpn_iphdr *) buf;
 
-        if (iph->ip_v == 6)
+        if (OPENVPN_IPH_GET_VER(iph->version_len) == 6)
         {
             type = htonl(AF_INET6);
         }
